﻿using System;
using System.Collections.Generic;

namespace KPIS.GERP.GFMS.MODEL
{
    public class M_FIM_Payroll
    {
        public int payroll_seq { get; set; }
        public string ref_no { get; set; }
        public int? emp_type_seq { get; set; }
        public DateTime req_date { get; set; }
        
        public int bgm_exp_grp_seq { get; set; }
        public int month_no { get; set; }
        public int year_no { get; set; }
        public int bgm_year_no { get; set; }
        public string title { get; set; }

        public int? ConId { get; set; }
        public decimal amount { get; set; }
        public int? bgm_proj_oper_exp_seq { get; set; }
        
        public string record_status { get; set; }
        public int created_by { get; set; }
        public DateTime created_when { get; set; }
        public int? updated_by { get; set; }
        public DateTime? updated_when { get; set; }
        
        public M_BGM_ProjectOperationExpense BgmProjectOperationExpense { get; set; }
        public M_ICM_MasContact IcmMasContact { get; set; }
        //public M_FIM_Payroll UpperPayroll { get; set; }
        public List<M_FIM_PayrollDeduction> PayrollDeductions { get; set; }
        
        public string mas_source_name
        {
            get { try{return BgmProjectOperationExpense.m_bgm_projectexpense.m_bgm_mas_source.bgm_source_name;} catch {}return "";}
        }

        public double deduction_total_amount
        {
            get { 
                decimal result = 0;
                foreach (var pd in PayrollDeductions?? new List<M_FIM_PayrollDeduction>())
                {
                    result += pd.amount;
                }
                return Convert.ToDouble(result);
            }
        }
    }
    
    public class M_FIM_PayrollDeduction
    {
        public int payroll_deduction_seq { get; set; }
        public int payroll_seq { get; set; }
        public string title { get; set; }
        public int? ConId { get; set; }
        public decimal amount { get; set; }
        
        public string record_status { get; set; }
        public int created_by { get; set; }
        public DateTime created_when { get; set; }
        public int? updated_by { get; set; }
        public DateTime? updated_when { get; set; }

        public M_FIM_Payroll Payroll { get; set; }
        public M_ICM_MasContact IcmMasContact { get; set; }

        public string amountStr { get { return amount.ToString("#,##0.00"); } }
        
    }
    public class M_ICM_MasContact
    {
        public int ConId { get; set; }
        public string NameTh { get; set; }
        public int ConCategory { get; set; }
        public int ConGrpId { get; set; }
    }

    public class M_FIM_PayrollDtls
    {
        public int payroll_dtls_seq { get; set; }
        public int year { get; set; }
        public int month { get; set; }
        public int emp_seq { get; set; }
        public double? salary { get; set; }
        public double? prof { get; set; }
        public double? extra_add { get; set; }
        public double? previous { get; set; }
        public double? tax { get; set; }
        public double? coop { get; set; }
        public double? house_bank { get; set; }
        public double? office_loan { get; set; }
        public double? pf_staff { get; set; }
        public double? other_deduction { get; set; }
        public double? net { get; set; }
        public double? pf_office { get; set; }
        public double? survey_add { get; set; }
    }
}
